package com.jintian.smart.kernel.flowable.engine;

import org.flowable.engine.*;
import org.flowable.engine.repository.DeploymentBuilder;
import org.flowable.engine.repository.DeploymentQuery;
import org.flowable.engine.repository.ProcessDefinitionQuery;
import org.flowable.engine.runtime.ChangeActivityStateBuilder;
import org.flowable.engine.runtime.ExecutionQuery;
import org.flowable.engine.runtime.ProcessInstanceQuery;
import org.flowable.task.api.TaskQuery;
import org.flowable.task.api.history.HistoricTaskInstanceQuery;
import org.springframework.beans.factory.annotation.Autowired;

public class DelegateProcessEngine {
    @Autowired
    private ProcessEngine processEngine;

    protected ProcessEngine processEngine() {
        return this.processEngine;
    }

    protected RepositoryService repositoryService() {
        return this.processEngine.getRepositoryService();
    }

    protected TaskService taskService() {
        return this.processEngine.getTaskService();
    }

    protected TaskQuery taskQuery() {
        return this.processEngine.getTaskService().createTaskQuery().includeIdentityLinks().includeTaskLocalVariables();
        // .includeProcessVariables().includeTaskLocalVariables().includeIdentityLinks().includeCaseVariables()

    }

    protected ProcessInstanceQuery processInstanceQuery() {
        return this.processEngine.getRuntimeService().createProcessInstanceQuery();
    }

    protected ChangeActivityStateBuilder changeActivityStateBuilder() {
        return this.processEngine.getRuntimeService().createChangeActivityStateBuilder();
    }

    protected ExecutionQuery executionQuery() {
        return this.processEngine.getRuntimeService().createExecutionQuery();
    }

    protected ManagementService managementService() {
        return this.processEngine.getManagementService();
    }

    protected RuntimeService runtimeService() {
        return this.processEngine.getRuntimeService();
    }

    protected HistoryService historyService() {
        return this.processEngine.getHistoryService();
    }

    protected DeploymentBuilder deployment() {
        return repositoryService().createDeployment();
    }

    protected DeploymentQuery deploymentQuery() {
        return repositoryService().createDeploymentQuery();
    }

    protected ProcessDefinitionQuery processDefinitionQuery() {
        return repositoryService().createProcessDefinitionQuery();
    }

    protected HistoricTaskInstanceQuery historicTaskInstanceQuery() {
        return this.historyService().createHistoricTaskInstanceQuery();
    }
}
